package com.study.springbootstudytwo.controller;


import com.study.springbootstudytwo.dto.PersonInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //访问地址--teststring是等下访问url时要加的地址
    @RequestMapping("/teststring")
    //直接返回一个字符串
    @ResponseBody
    public String testString(@RequestBody(required = false) PersonInfo personInfo){
        return "大家好";
    }


    @RequestMapping("/testRedis")
    //直接返回一个字符串
    public String testRedis(){
        return stringRedisTemplate.opsForValue().get("name");
    }
}

